package com.hengxinguotong.zhihuichengjian.treeview;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hengxinguotong.zhihuichengjian.R;
import com.hengxinguotong.zhihuichengjian.bean.Structure;

import java.util.List;

import butterknife.BindView;


/**
 * @CopyRight 恒信国通信息科技
 * @Author wulei
 * @Date 2018/8/21
 */

public class FirstFloorAdapter extends RecyclerAdapter<Structure, FirstFloorAdapter.FirstFloorViewHolder> {

    public FirstFloorAdapter(Context context, List<Structure> dataList) {
        super(context, dataList);
    }

    @Override
    public FirstFloorViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.layout_first, null);
        return new FirstFloorViewHolder(view);
    }

    @Override
    public void onBindViewHolder(FirstFloorViewHolder holder, int position) {
        holder.bindData(position);
    }

    public class FirstFloorViewHolder extends RecyclerAdapter.BaseViewHolder {
        @BindView(R.id.name)
        TextView name;
        @BindView(R.id.right_icon)
        ImageView rightIcon;

        public FirstFloorViewHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void bindData(int position) {
            Structure structure = dataList.get(position);
            name.setText(structure.getName());
            LinearLayout.LayoutParams rootLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            rootLayoutParams.setMargins(30, 0, 0, 0);
            itemView.setLayoutParams(rootLayoutParams);
        }
    }
}
